package org.istt.service.impl;

import java.util.List;

import org.istt.dao.AttachFileDao;
import org.istt.domain.AttachFile;
import org.istt.domain.Category;
import org.istt.domain.CategoryType;
import org.istt.service.AttachFileManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "attachFileManager")
public class AttachFileManagerImpl implements AttachFileManager {
    @Autowired
    AttachFileDao dao;
    
    public void setAttachFileDao(AttachFileDao dao) {
        this.dao = dao;
    }

    public List<AttachFile> getAttachFiles() {
        return dao.getAttachFiles();
    }

    public AttachFile getAttachFile(String attachFileId) {
        return dao.getAttachFile(Long.valueOf(attachFileId));
    }

    public void saveAttachFile(AttachFile attachFile) {
        dao.saveAttachFile(attachFile);
    }

    public void removeAttachFile(String attachFile) {
        dao.removeAttachFile(Long.valueOf(attachFile));
    }

	@Override
	public List<AttachFile> searchAttachFile(Category category, String attachFileName, CategoryType categoryType) {
		
		return dao.searchAttachFile(attachFileName, category, categoryType);
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.istt.service.AttachFileManager#searchByCateId(java.lang.Long)
	 */
	@Override
	public List<AttachFile> searchByCateId(Long cateId) {
		return dao.findByCateId(cateId);
	}
	
	/*
	 * (non-Javadoc)
	 * @see org.istt.service.AttachFileManager#getByCatIdAndCatTypeId(java.lang.Long, java.lang.Long)
	 */
	@Override
	public List<AttachFile> getByCatIdAndCatTypeId(Long categoryId,
			Long categoryTypeId) {
		return dao.findByCatIdAndCatTypeId(categoryId, categoryTypeId);
	}
	

	@Override
	public boolean isUnique(String[] fields, String[] value, Long id, Long cateId, Long cateTypeId, Long docTypeId) {
		return dao.isUnique(fields, value, id, cateId, cateTypeId, docTypeId);
	}

	@Override
	public int countFileUseAttach(Long attachFileId) {
		// TODO Auto-generated method stub
		return dao.countFileUseAttach(attachFileId);
	}

	@Override
	public List<AttachFile> findAttachFileByCate(Long categoryId, Long categoryTypeId) {
		// TODO Auto-generated method stub
		return dao.findAttachFile(categoryId, categoryTypeId);
	}

	@Override
	public int countAttachFile(Long cateId, Long cateTypeId, Long docTypeId) {
		// TODO Auto-generated method stub
		return dao.getRecordCount(cateId, cateTypeId, docTypeId);
	};
	
}
